package dissertation.services.ejbmodule;

import com.intellij.openapi.module.JavaModuleType;
import com.intellij.openapi.module.Module;
import com.intellij.openapi.module.ModuleType;
import dissertation.common.constants.Constants;

public class EJBModuleService implements IEJBModuleService {
    @Override
    public void addEJBSupportToModule(Module module, String version) {
        module.setOption(Constants.EJB_VERSION_FIELD_NAME, version);
    }

    @Override
    public boolean isAcceptableModuleType(ModuleType moduleType) {
        return moduleType instanceof JavaModuleType;
    }

    @Override
    public boolean isEJBModule(Module module) {
        return module.getOptionValue(Constants.EJB_VERSION_FIELD_NAME) != null;
    }

    @Override
    public String getEJBVersion(Module module) {
        return module.getOptionValue(Constants.EJB_VERSION_FIELD_NAME);
    }

    @Override
    public String[] getSupportedEJBVersions() {
        return Constants.SUPPORTED_VERSIONS;
    }
}
